package services

import (
	"database/sql"
	db "dhuviewer/db_query"
	"fmt"
	"log"
)

// const (
// 	hostname      = "101.132.222.222"
// 	host_port     = 5432
// 	username      = "postgres"
// 	password      = "F0T7RuFd3z"
// 	database_name = "postgres"
// )
const (
	hostname      = "101.132.222.222"
	host_port     = 5432
	username      = "production"
	password      = "just4fun"
	database_name = "postgres"
)

var (
	queries *db.Queries
	pq      *sql.DB
)

func init() {
	var err error
	pg_con_string := fmt.Sprintf("port=%d host=%s user=%s password=%s dbname=%s sslmode=disable", host_port, hostname, username, password, database_name)
	pq, err = sql.Open("postgres", pg_con_string)
	if err != nil {
		log.Fatal(err)
	}
	queries = db.New(pq)
}
